package com.dq.Service.Impl;

import com.dq.Mapper.ClassMapper;
import com.dq.Pojo.Classtable;
import com.dq.Service.ClassService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ClassServiceImpl implements ClassService {

    @Autowired
    private ClassMapper classMapper;

    @Override
    public void addclass(Classtable classtable) {
        classMapper.addclass(classtable);
    }

    @Override
    public PageInfo<Classtable> findAll(Integer pageNum, Integer pageSize, String classname) {
        PageHelper.startPage(pageNum,pageSize);
        List<Classtable> classtableList=classMapper.findByname(classname);
        PageInfo<Classtable> pageInfo=new PageInfo<>(classtableList);
        return pageInfo;
    }

    @Override
    public void delete(Integer id) {
        classMapper.delete(id);
    }

    @Override
    public Classtable getByid(Integer id) {
        return classMapper.getByid(id);
    }

    @Override
    public void update(Classtable classtable) {
        classMapper.update(classtable);
    }

    @Override
    public List<Classtable> find() {
        return  classMapper.find();

    }
}
